package daily.may0509;

import java.util.*;

public class GenericAdvantageTest {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        //list.add(1);//这么写会报错
        //使用迭代器遍历list集合
        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            //无需强制转换
            String s = it.next();
            System.out.print(s);//张三李四王五
        }
    }
}
